package com.source.multithread.singleton;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @Author wengqy
 * @Date 2020/12/25
 */
public class SingleTonReflect {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
       /* SingleTon singleTon1 = SingleTon.getSingleTon();
        Constructor<SingleTon> constructor = SingleTon.class.getDeclaredConstructor(null);
        constructor.setAccessible(true);
        SingleTon singleTon2 = constructor.newInstance();
        System.out.println(singleTon1==singleTon2);
        System.out.println(singleTon1.hashCode());
        System.out.println(singleTon2.hashCode());*/


        Constructor<SingleTon> constructor = SingleTon.class.getDeclaredConstructor(null);
        constructor.setAccessible(true);
        SingleTon singleTon1 = constructor.newInstance();
        SingleTon singleTon2 = constructor.newInstance();
        System.out.println(singleTon1==singleTon2);
        System.out.println(singleTon1.hashCode());
        System.out.println(singleTon2.hashCode());


    }
}
